package Visitor;

import Entities.Advantages.DecreaseBallSpeed;
import Entities.Advantages.DecreaseBarSize;
import Entities.Advantages.IAdvantage;
import Entities.Advantages.IncreaseBallSpeed;
import Entities.Advantages.IncreaseBarSize;
import Entities.Ball;
import Entities.Bar;
import Entities.Boundary;
import Entities.Brick;
import Entities.Drawable;
import Entities.Hinder;
import java.awt.Color;
import java.awt.Graphics;

public class PaintVisitor implements IVisitor {

    private Graphics g;

    public PaintVisitor(Graphics g) {
        this.g = g;
    }

    @Override
    public Drawable visit(Bar bar) {
        g.drawRect(bar.getX(), bar.getY(), bar.getWidth(), bar.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Ball ball) {
        if (ball.getDx() == 0 && ball.getDy() == 0) {
            g.drawString("Press SPACE", 170, 200);
        }
        g.fillOval(ball.getX(), ball.getY(), ball.getRadio() * 2, ball.getRadio() * 2);
        return null;
    }

    @Override
    public Drawable visit(Boundary boundary) {
        g.drawRect(boundary.getX(), boundary.getY(), boundary.getWidth(), boundary.getHeight());
        return null;
    }

    @Override
    public Drawable visit(IAdvantage advantage) {
        //g.fillRect(advantage.getX(), advantage.getY(), advantage.getWidth(), advantage.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Brick brick) {
        switch (brick.getResistance()) {
            case 1: {
                g.setColor(Color.blue);
                break;
            }
            case 2: {
                g.setColor(Color.red);
                break;
            }
            case 3: {
                g.setColor(Color.yellow);
                break;
            }
            case 4: {
                g.setColor(Color.green);
                break;
            }
            default: {
            }
        }
        if (brick.getResistance() != 0) {
            g.fillRect(brick.getX(), brick.getY(), brick.getWidth(), brick.getHeight());
            g.setColor(Color.black);
        }
        g.drawRect(brick.getX(), brick.getY(), brick.getWidth(), brick.getHeight());
        return null;
    }

    @Override
    public Drawable visit(Drawable drawable) {
        return null;
    }

    @Override
    public Drawable visit(Hinder hinder) {
        return null;
    }

    @Override
    public Drawable visit(DecreaseBarSize dicreaseBarSize) {
        g.setColor(Color.red);
        g.fillRect(dicreaseBarSize.getX(), dicreaseBarSize.getY(), dicreaseBarSize.getWidth(), dicreaseBarSize.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(IncreaseBarSize increaseBarSize) {
        g.setColor(Color.green);
        g.fillRect(increaseBarSize.getX(), increaseBarSize.getY(), increaseBarSize.getWidth(), increaseBarSize.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(DecreaseBallSpeed drecreaseBallSpeed) {
        g.setColor(Color.green);
        g.fillRect(drecreaseBallSpeed.getX(), drecreaseBallSpeed.getY(), drecreaseBallSpeed.getWidth(), drecreaseBallSpeed.getHeight());
        g.setColor(Color.black);
        return null;
    }

    @Override
    public Drawable visit(IncreaseBallSpeed increaseBallSpeed) {
        g.setColor(Color.red);
        g.fillRect(increaseBallSpeed.getX(), increaseBallSpeed.getY(), increaseBallSpeed.getWidth(), increaseBallSpeed.getHeight());
        g.setColor(Color.black);
        return null;
    }
}
